		function brandNewOneFunc(urlpath,param){//前后端数据交互,ajax
			$.ajax({
				url:urlpath,
				datatype:"json",
				type:"post",
				data:param,
				success:function(data){
					 result=data;
					showSeatInfo(data[0]);//座位表格信息的分页显示
					pageNav();
				}
			})
		}
		var op="queryByPage";
		var array={"op":op};
		brandNewOneFunc("SeatManageServlet",array);//座位信息初始化

		
		function pageNav(){
			layui.use('laypage', function(){
				  var laypage = layui.laypage;
				  //执行一个laypage实例
				  laypage.render({
				    elem: 'pagediv' //注意，这里的 test1 是 ID，不用加 # 号
				    ,count: result[1].totalCount //数据总数，从服务端得到
				    ,curr:   result[1].page
				    ,limit:   result[1].pageSize
				    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
				  ,jump: function(obj, first){
					    page=obj.curr;
					    pageSize=obj.limit;
					    if(!first){
					      //do something
					       var array={"op":"queryByPage","page":obj.curr,"pageSize":obj.limit};
					       brandNewOneFunc("SeatManageServlet",array);
					      }
				    }
				  });
				});
		}
		
			    $(function () {
			        let form = layui.form
			            ,laydate = layui.laydate,
			            laypage = layui.laypage,
			            layer = layui.layer,
			            table = layui.table;
			        //删除座位
			        $('body').on("click",".btn-del",function () {
			        	var deleSeatStr=""
				         var pre = $(this);
				         layui.layer.confirm('确定要删除么？',{
				                btn:['确定','取消']
				        },function () {
				        	layui.layer.closeAll('dialog');
				        	$('#seatTable').find('input:checked').each(function () {
				        	            console.log($(this).parent().parent().find("td").children().eq(1).val());
				        	            deleSeatStr = deleSeatStr+$(this).parent().parent().find("td").children().eq(1).val()+",";
				        	  });
							 var array="&op=deleteSeatById&page="+page+"&pageSize="+pageSize+"&deleSeatStr="+deleSeatStr+"";
							brandNewOneFunc("SeatManageServlet",array);
				        })
				    });
			        
			        //修改座位信息
			        $('body').on("click",".btn-edit",function () {
			        	var deleSeatStr=""
				         var pre = $(this);
				         layui.layer.confirm('确定要修改吗？',{
				                btn:['确定','取消']
				        },function () {
				        	layui.layer.closeAll('dialog');
				        	var Eseatno=$(pre).parent().parent().find("td").children().eq(1).val();
				        	var Rno=$(pre).parent().parent().find("td").children().eq(2).val();
				        	var Estatus=$(pre).parent().parent().find("td").children().eq(3).val();
							 var array="&op=editSeat&page="+page+"&pageSize="+pageSize+"&Eseatno="+Eseatno+"&Rno="+Rno+"&Estatus="+Estatus+"";
							brandNewOneFunc("SeatManageServlet",array);
				        })
				    });

			    });
	     //批量增加座位
		function addSeatByNum(){
		    var array=$('#myModal_addSeatByNum').serialize();
			 var pageArray="&op=addSeatByNum&page="+page+"&pageSize="+pageSize+"";
			 var combinedArray=array+pageArray;
			 brandNewOneFunc("SeatManageServlet",combinedArray);
		}
		   //批量删除座位
		function deleSeatByNum(){
		    var array=$('#myModal_deleSeatByNum').serialize();
			 var pageArray="&op=deleteSeatByNum&page="+page+"&pageSize="+pageSize+"";
			 var combinedArray=array+pageArray;
			 brandNewOneFunc("SeatManageServlet",combinedArray);
		}
		
		function searchSeat(){//查询座位信息
				   var   keywords=document.getElementById("searchContent").value;
				    var array={"op":"queryByPage","page":page,"pageSize":pageSize,"keywords":keywords};
				    brandNewOneFunc("SeatManageServlet",array);
		}
		
//显示表格数据
function showSeatInfo(jsonstr){
	console.log("调用showSeatInfo");
	var data = jsonstr;
	document.getElementById("tbody1").innerHTML="";
	var HTML ="";
		if(data!=null)
		{
			for(var i=0;i<data.length;i++){
			 HTML += '<tr>\n' +
			 ' 							  <td>\n' +
			 ' 									<input type="checkbox" name="seat" onclick=$().setSelectallStatus()>\n' +
			 '  						  </td>\n' +
             '                            <td>\n' +
             '                                <input type="layui-input" name="Eseatno" readonly="readonly" value="'+data[i].Eseatno+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             ' 										<input class="layui-input" name="Rno"  readonly="readonly" value="'+data[i].Rno+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             '                           <select name="Estatus" lay-filter="">\n' +
             '  								<option value="">'+data[i].Estatus+'</option>\n' +
             '  								<option value="损坏">损坏</option>\n' +
             '  								<option value="未预约">未预约</option>\n' +
             '  						</select>\n' +
             '                            </td>\n' +
             '                            <td style="text-align: center" >\n' +
             '                            <button type="button" class="layui-btn layui-btn-danger btn-edit"  >修改</button></td>\n' +
             '                        </tr>';
			  }
			document.getElementById("tbody1").innerHTML=HTML;
       }
}

//全选，反选
$(function(){
	$("#selectAll").click(function(){
	var allgoods=$("input[name='seat']");
	if($("#selectAll").get(0).checked==false){		
	for(var i=0;i<allgoods.length;i++){allgoods[i].checked=false;}
	}
	else{for(var i=0;i<allgoods.length;i++)
	{allgoods[i].checked=true;}
	}
    });
});

$(function(){
	$("#reverseSelect").click(function (){
	var allgoods=$("input[name='seat']");
	for(var i=0;i<allgoods.length;i++)
	{
		allgoods[i].checked=!allgoods[i].checked;
	}
	});
});

$(function(){
	$.fn.setSelectallStatus=function(){
		
		var allgoods=$("input[name='seat']");
		for(var i=0;i<allgoods.length;i++)
		{
			if(allgoods[i].checked==false){$("#selectAll").get(0).checked=false;return;}	
		}
		$("#selectAll").get(0).checked=true;
	}
});
		